package com.tepth.busfix.network;

import com.tepth.busfix.bean.reponse.AlarmType;
import com.tepth.busfix.bean.reponse.BusRepairHistory;
import com.tepth.busfix.bean.reponse.BusType;
import com.tepth.busfix.bean.reponse.Process;
import com.tepth.busfix.bean.reponse.Repair;
import com.tepth.busfix.bean.reponse.SearchPartResult;
import com.tepth.busfix.bean.reponse.TroubleClassification;
import com.tepth.busfix.bean.reponse.TroubleContent;
import com.tepth.busfix.bean.reponse.User;
import com.tepth.busfix.bean.reponse.Version;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

/**
 * Created by zhangyu on 2016/6/15.
 */
public interface ApiService {
    @GET(ApiUrl.USER_LOGIN)
    Observable<ApiModel<User>> login(@Query("loginName") String userName,
                                     @Query("password") String password);

    @GET(ApiUrl.ALARM_INFO)
    Observable<ApiModel<List<AlarmType>>> alarmInfo(@Query("authKey") String authKey,
                                                    @Query("vehicleId") String vehicleId);

    @GET(ApiUrl.ALARM_INFO_BY_TROUBLE)
    Observable<ApiModel<List<AlarmType>>> alarmInfoByTrouble(@Query("authKey") String authKey,
                                                             @Query("vehicleId") String vehicleId,
                                                             @Query("troubleTypeId") long id);


    @GET(ApiUrl.BUS_TYPE)
    Observable<ApiModel<List<BusType>>> busType(@Query("authKey") String authKey);

    @GET(ApiUrl.REPAIR_INFO)
    Observable<ApiModel<Repair>> repairInfo(@Query("authKey") String authKey,
                                            @Query("id") long id);

    @GET(ApiUrl.TROUBLE_AND_SUGGEST)
    Observable<ApiModel<List<TroubleClassification>>> troubleClassification(@Query("authKey") String authKey);

    @GET(ApiUrl.OPERATOR_LIST)
    Observable<ApiModel<List<TroubleContent.Operation>>> operationList(@Query("authKey") String authKey);

    @GET(ApiUrl.SEARCH_PART)
    Observable<ApiModel<SearchPartResult>> searchPart(@Query("authKey") String authKey,
                                                      @Query("name") String name);

    @POST(ApiUrl.START_REPAIR)
    @FormUrlEncoded
    Observable<ApiModel<String>> startRepair(@Field("authKey") String authKey,
                                             @Field("repairInfo") String body);

    @GET(ApiUrl.COMMON_COMPONENT)
    Observable<ApiModel<SearchPartResult>> commonComponent(@Query("authKey") String authKey,
                                                           @Query("top") int count);

    @GET(ApiUrl.APP_UPDATE)
    Observable<ApiModel<Version>> getVersion(@Query("appname") String appName);

    @GET(ApiUrl.GET_PROCESS_BY_TROUBLE)
    Observable<ApiModel<List<Process>>> getProcessBytrouble(@Query("authKey") String authKey,
                                                            @Query("troubleTypeId") long troubleTypeId,
                                                            @Query("troubleTypeName") String troubleName);

    @POST(ApiUrl.CANCEL_PUNCH_CARD)
    @FormUrlEncoded
    Observable<ApiModel<String>> cancelPunchCard(@Field("authKey") String authKey,
                                                 @Field("json") String body);

    @POST(ApiUrl.REWORK)
    @FormUrlEncoded
    Observable<ApiModel<String>> rework(@Field("authKey") String authKey,
                                        @Field("repairInfo") String body);

    @GET(ApiUrl.REPAIR_HISTORY)
    Observable<ApiModel<List<BusRepairHistory>>> getRepairHistory(@Query("authKey") String authKey,
                                                                  @Query("vehicleCode") String code);
}
